package com.qcxk.yuqian.system.component.token.front;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class FrontLoginInterceptorConfig implements WebMvcConfigurer {

    @Bean
    public HandlerInterceptor getFrontTokenInterceptor() {
        return new FrontTokenInterceptor();
    }

    //    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry){
//        registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/img/");
//    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册TokenInterceptor拦截器
        InterceptorRegistration registration = registry.addInterceptor(getFrontTokenInterceptor());
        registration.addPathPatterns(       //只拦截前台验证 token 的 url
                "/testUser",
                "/bnsUserextra/getUserAmount",
                "/bnsUsers/chgPayPassword",
                "/bnsTraderecord/queryTraderecordListFront",
                "/bnsPaymentrecord/queryPaymentrecordListFront",
                "/bnsPaymentrecord/cz",
                "/bnsPaymentrecord/tx",
                "/frontExit",
                "/bnsTraderecord/reserveAndBuy",
                "/bnsUsers/chgLoginPassword"
        );
    }
}
